package factory.method;

/**
 * Remarks:
 * Class name :Consumer
 * Date :2023/2/16 23:22
 * Author:杨俊源
 */
public class Consumer {
    public static void main(String[] args) {
        Car car1 = new WuLingFactory().getCar();
        Car car2 = new TeslaFactory().getCar();
        Car car3 = new MobaiFactory().getCar();

        car1.name();
        car2.name();
        car3.name();
    }
}

interface Car {
    void name();
}

interface CarFactory{
    Car getCar();
}

class TeslaFactory implements CarFactory{
    @Override
    public Car getCar() {
        return new Tesla();
    }
}

class WuLingFactory implements CarFactory{
    @Override
    public Car getCar() {
        return new WuLing();
    }
}

class MobaiFactory implements CarFactory{
    @Override
    public Car getCar() {
        return new Mobai();
    }
}

class WuLing implements Car {
    @Override
    public void name() {
        System.out.println("五菱宏光");
    }
}

class Tesla implements Car {

    @Override
    public void name() {
        System.out.println("特斯拉");
    }
}

class Dazhong implements Car {
    @Override
    public void name() {
        System.out.println("大众");
    }
}

class Mobai implements Car {
    @Override
    public void name() {
        System.out.println("膜拜单车");
    }
}



